﻿namespace EFS.RC.ConversationBrowser.Common
{
	public static class Main
	{
		public const System.Int32 MillisecondsBetweenRepetitiveAsyncCalls = 30;

		/// Property HostFullUrl: Get
		public static System.String HostFullUrl
		{
			get
			{
				// crete url
				System.Text.StringBuilder sbUrl = new System.Text.StringBuilder();
				sbUrl.AppendFormat("{0}://{1}:{2}",
					System.Windows.Application.Current.Host.Source.Scheme,
					System.Windows.Application.Current.Host.Source.Host,
					System.Windows.Application.Current.Host.Source.Port);

				// ok
				return sbUrl.ToString();
			}
		}

		public static void ViewConversationExternal(
			System.Guid conversationGuid,
			System.DateTime conversationDate)
		{
			// crete url
			System.Text.StringBuilder sbUrl = new System.Text.StringBuilder();
			sbUrl.AppendFormat("{0}/index.aspx?cmd=view_ext&guid={1}&date={2}",
				HostFullUrl,
				conversationGuid,
				conversationDate.ToString("yyyy-MM-dd"));

			// open
			System.Windows.Browser.HtmlPage.Window.Navigate(
				new System.Uri(sbUrl.ToString()),
				"__blank",
				"fullscreen=no,status=yes,toolbar=no,location=yes,menubar=no,directories=no,resizable=yes,scrollbars=yes");
		}
	}

}